package singleton;
/**
 * 单例模式的
 */
public class SingletonTest2 {

    public static void main(String[] args) {
        Order o1 = Order.getInstance();
        Order o2 = Order.getInstance();

        System.out.println( o1 == o2);
    }

}

class Order{

    //1.私有化构造器
    private Order(){
    }

    //2.定义私有化静态对象,不进行初始化
    private static Order instance =null;

    //3.创建静态的get方法
    public static Order getInstance(){
        if ( instance == null){
            instance = new Order();
        }
        return instance;
    }


}